package com.yanqu.road.server.cmd.wingroom.message;

import com.yanqu.road.pb.wingroom.WingRoomProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

/**
 * @author ：zfr
 * @date ：2022/3/22 15:39
 */
@Cmd(code = CrossProtocol.C_WING_ROOM_COPY_OTHER_PLAN_RESP, desc = "拷贝别人的方案返回")
public class CrossCopyOtherPlanRespCmd implements Command {
    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        WingRoomProto.GetOtherPlanRespCrossMsg respCrossMsg = WingRoomProto.GetOtherPlanRespCrossMsg.parseFrom(packet.getBytes());
        WingRoomProto.GetOtherPlanCrossRespMsg.Builder respMsg = WingRoomProto.GetOtherPlanCrossRespMsg.newBuilder();
        respMsg.addAllRegion(respCrossMsg.getRegionList());
        respMsg.setRespMsg(respCrossMsg.getRespMsg());
        respMsg.setPlanName(respCrossMsg.getPlanName());
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_WING_ROOM_COPY_OTHER_PLAN_RESP, respMsg);
        MessageHelper.sendPacket(respCrossMsg.getOriServerId(), respCrossMsg.getOriUserId(), message);
    }
}
